package client.view;

import javax.swing.*;
import java.awt.*;

/**
 * Created by IntelliJ IDEA.
 * User: sam
 * Date: 16/02/12
 * Time: 06:19
 * To change this template use File | Settings | File Templates.
 */

class DownloadPanel extends JPanel {

    JSplitPane splitPane;
    DownloadControlPanel downloadControlPanel;
    DownloadResultsPanel downloadResultsPanel;

    public DownloadPanel() {
        // hence wy its important to have empty constructors
        // as downloadResultsPanel is passed to RepositoriesPanel
        // in its constructor, so need to instantiate here
        // not in init() below, otherwise its null
        // when passed in to RepositoriesPanel
        downloadResultsPanel = new DownloadResultsPanel();
        downloadControlPanel = new DownloadControlPanel();
    }

    public void init(UploadPanel uploadPanel) {

        ReportsPanel.log("DownloadPanel.init("+uploadPanel+")");

        setLayout( new GridLayout( 1, 1 ) );

        splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
        splitPane.setOneTouchExpandable(true);
        splitPane.setDividerLocation(305);

        //downloadResultsPanel = new DownloadResultsPanel();
        //downloadControlPanel = new DownloadControlPanel();

        // TODO do not need panels at set-up time,
        // only run-time communication. Have init()'s
        // just construct themselvs first, then pass panel references.
        uploadPanel.init(downloadControlPanel);
        downloadControlPanel.init(downloadResultsPanel, uploadPanel);
        downloadResultsPanel.init(downloadControlPanel);


        splitPane.setLeftComponent(downloadControlPanel);
        splitPane.setRightComponent(downloadResultsPanel);

        add(splitPane);
    }
}
